/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"E8FE692E-8B88-41D2-B0A0-4B5FA14D5ABA",variableType:93}
 */
var fFechaHasta = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"AF939EDA-8062-439B-87D4-009529A0E074",variableType:93}
 */
var fFechaDesde = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"111AF8ED-1C31-47EC-B69D-8D539C2649E9",variableType:4}
 */
var fTipoPago = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"5E6F2B49-BA22-4914-B87C-88A8CB7BA6FA",variableType:4}
 */
var fProveedor = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"84543427-8F19-4606-A07A-805A574AC655"}
 */
function modificar(event) {
	databaseManager.setAutoSave(false)
	var $win = application.createWindow('ALTA_PAGOS',JSWindow.MODAL_DIALOG)
	if (fecha_factura.getMonth() == application.getServerTimeStamp().getMonth())
	{
		forms.pagos_dtl.controller.readOnly = false
	}
	else
	{
		forms.pagos_dtl.controller.readOnly = true
	}
	forms.pagos_dtl.controller.show($win)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C778C698-C08A-4876-8415-8B6A78516ABC"}
 * @AllowToRunInFind
 */
function buscar(event) {
	controller.find()
	
	proveedor_id = fProveedor
	tipo_pago_id = fTipoPago
	
	if (fFechaDesde != null && fFechaHasta != null)
	{
		var fd = new Date(fFechaDesde.getFullYear(), fFechaDesde.getMonth(),fFechaDesde.getDate(),0,0,0,0)
		var fh = new Date(fFechaHasta.getFullYear(), fFechaHasta.getMonth(),fFechaHasta.getDate(),23,59,59,997)
		fecha_factura = '#'+utils.dateFormat(fh,'dd-MM-yyyy')+' ... '+ utils.dateFormat(fd,'dd-MM-yyyy')+'|dd-MM-yyyy'
	}
	if (controller.search() == 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso','No se encontraron resultados','OK')
	}
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"18853AAB-1378-467B-8A1A-D2A0EACF5049"}
 */
function nuevo(event) {
	databaseManager.setAutoSave(false)
	var $win = application.createWindow('ALTA_PAGOS',JSWindow.MODAL_DIALOG)
	forms.pagos_dtl.controller.newRecord()
	forms.pagos_dtl.controller.readOnly = false
	forms.pagos_dtl.controller.show($win)
}
